#ifndef __PCA9557_H__
#define __PCA9557_H__
#include "driver/gpio.h"
#include "driver/i2c.h"
#include "freertos/FreeRTOS.h"
#include "freertos/portmacro.h"

/* 引脚与相关参数定义 */
#define I2C_SDA           (GPIO_NUM_1)   // SDA引脚
#define I2C_SCL           (GPIO_NUM_2)   // SCL引脚


#define I2C_NUM           (0)            // I2C外设
#define I2C_FREQ_HZ       100000         // 100kHz
/*********************************************************************
 * ************************** IO 扩展芯片******************************/
#define PCA9557_INPUT_PORT              0x00
#define PCA9577_OUTPUT_PORT             0x01
#define PCA9577_POLARITY_INVERSION_PORT 0x02
#define PCA9557_CONFIGURATION_PORT      0x03


#define LCD_CS_GPIO                     BIT(0)              //PCA9557_GPIO_NUM_1
#define PA_EN_GPIO                      BIT(1)              //PCA9557_GPIO_NUM_2
#define DVP_PWDN_GPIO                   BIT(2)              //PCA9557_GPIO_NUM_3

#define PCA9557_SENSOR_ADDR             0x19                /*Slave address of the PCA9557 sensor*/

#define SET_BITS(_m, _s, _v)  ((_v) ? (_m)|((_s)) : (_m)&~((_s)))


esp_err_t I2C_init(void);
extern void pca9557_init(void);
extern void lcd_cs(uint8_t level);
extern void pa_en(uint8_t level);
extern void dvp_pwdn(uint8_t level);
#endif